package com.hua.api.core.framework.sms;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SmsSenderProcess implements Runnable {

    public ExecutorService executor; // 线程池
    public List<SmsSendThread> list; // 队列
    public boolean isMaps = true;

    public SmsSenderProcess() {
        this.executor = Executors.newFixedThreadPool(15);
        this.list = new ArrayList<>();
    }

    public void setList(List<SmsSendThread> list){
        this.list = list;
    }

    @Override
    public void run() {
        for(SmsSendThread smsSendThread : list) {
            this.executor.submit(smsSendThread);
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
        this.executor.shutdown();
    }

}
